import { createApp } from "vue";
import App from "./App.vue";
import { createPinia } from "pinia"; // pinia
import piniaPluginPersist from "pinia-plugin-persistedstate"; // pinia 持久化插件
import router from "./router/index"; // 全局路由
import "uno.css"; // unocss
import "@less/index.less"; // 全局 css 样式

import Codemirror from "vue-codemirror";
import { oneDark } from "@codemirror/theme-one-dark";
import { javascript } from "@codemirror/lang-javascript";

const app = createApp(App);

// 全局捕获错误
app.config.errorHandler = (err, vm, info) => {
	console.log("e123123rr");
	console.log(err);
	console.log(info);

	// 处理错误
	// `info` 是 Vue 特定的错误信息，比如错误所在的生命周期钩子
};

app.use(Codemirror, {
	autofocus: true,
	disabled: false,
	indentWithTab: true,
	lineNumbers: true,
	styleActiveLine: true, // 当前行背景亮
	lineWrapping: true, // 自动换行
	theme: "default",
	line: true,
	tabSize: 2,
	style: { fontSize: "16px" },
	foldGutter: true,
	placeholder: "Code goes here...",
	extensions: [javascript(), oneDark]
	// ...
});

app.use(createPinia().use(piniaPluginPersist)).use(router).mount("#app");
